#! /usr/bin/env bash
myHERE=$(cd "$(dirname "$0")";pwd)
source "$myHERE/global_build_OSX.command"
mySetupBUILDDIR boost
cd "$myHERE/boost"
read -d '' myCOMMAND <<"EOF"
./bootstrap.sh \
--with-toolset=darwin \
--prefix="$my3RDINSTALLDIR" \
--libdir="$my3RDLIBRARYDIR" \
--includedir="$my3RDINCLUDEDIR" \
--with-icu="$myHERE/icu" \
--with-libraries=program_options,container,exception,filesystem,regex,system,test,thread,math,python,log \
cxxflags="$myCXXFLAGS" \
linkflags="$myLDFLAGS" \
address-model=32_64 \
threading=multi \
macos-version=$myOSX \
macos-version-min=$myOSX \
boost.locale.iconv=off \
define=BOOST_LOG_WITHOUT_EVENT_LOG \
debug-configuration \
roo~/Developer/Platforms/MacOSX.platform/Developer/

EOF

echo "Building BOOST from $myHERE"
myEval "$myCOMMAND"

read -d '' myCOMMAND <<"EOF"
./b2 clean
EOF
myEval "$myCOMMAND"

read -d '' myCOMMAND <<"EOF"
./b2 \
-d+2 \
--build-dir="$myBUILDDIR" \
--stagedir="$my3RDINSTALLDIR" \
link=static \
define=U_STATIC_IMPLEMENTATION=1 \
define=BOOST_HAS_ICU \
threading=multi \
boost.locale.iconv=off \
macosx-version=$myOSX \
macosx-version-min=$myOSX \
cxxflags="$myCXXFLAGS" \
linkflags="$myLDFLAGS" \
stage
EOF
myEval "$myCOMMAND"
./b2 \
-d+2 \
--build-dir="$myBUILDDIR" \
--stagedir="$my3RDINSTALLDIR" \
link=static \
define=U_STATIC_IMPLEMENTATION=1 \
define=BOOST_HAS_ICU \
threading=multi \
boost.locale.iconv=off \
macosx-version=$myOSX \
macosx-version-min=$myOSX \
cxxflags="$myCXXFLAGS" \
linkflags="$myLDFLAGS" \
stage

exit 0

myCFLAGS="-arch x86_64 -isysroot $myMACOSXSDKDIR -mmacosx-version-min=$myOSX -I$my3RDINCLUDEDIR"
myCXXFLAGS="$myCFLAGS -stdlib=$myOSXSTDLIB --std=$myOSXCC"

./b2 -d+2 \
-sICU_PATH="$my3RDINSTALLDIR" \
toolset=darwin \
define=U_STATIC_IMPLEMENTATION=1 \
define=BOOST_HAS_ICU \
threading=multi \
cxxflags="-stdlib=$myOSXSTDLIB" \
linkflags="-stdlib=$myOSXSTDLIB" \
stage

./b2 \
-d+2 -d+4 \
--build-dir="$myBUILDDIR" \
--stagedir="$my3RDINSTALLDIR" \
-sICU_PATH="$my3RDINSTALLDIR" \
toolset=darwin \
define=U_STATIC_IMPLEMENTATION=1 \
define=BOOST_HAS_ICU \
threading=multi \
link=static \
runtime-link=static \
cxxflags="-stdlib=$myOSXSTDLIB" \
linkflags="-stdlib=$myOSXSTDLIB" \
stage

./b2 -d+2 -d+4 --build-dir="$myBUILDDIR" --stagedir="$my3RDINSTALLDIR" -sICU_PATH="$my3RDINSTALLDIR" toolset=darwin define=U_STATIC_IMPLEMENTATION=1 define=BOOST_HAS_ICU threading=multi link=static runtime-link=static cxxflags="-stdlib=$myOSXSTDLIB" linkflags="-stdlib=$myOSXSTDLIB" stage
exit 0
./b2 -d+2 --build-dir="$myBUILDDIR" --stagedir="$my3RDINSTALLDIR" -sICU_PATH="$my3RDINSTALLDIR" toolset=darwin define=U_STATIC_IMPLEMENTATION=1 define=BOOST_HAS_ICU threading=multi link=static runtime-link=static cxxflags="-stdlib=$myOSXSTDLIB" linkflags="-stdlib=$myOSXSTDLIB" boost.locale.iconv=on  cxxflags="-I$my3RDINCLUDEDIR" linkflags="-L$my3RDLIBRARYDIR" stage

// ./b2  -d+2 […] to be more verbose
